<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>页面</title>
    <script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/loading.js"></script>
    <link href="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/theme-chalk/index.css" rel="stylesheet">
</head>
<body>
<div id="app">
    <el-container >
        <el-header>
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item ><a href="/message/index.page">首页</a></el-breadcrumb-item>
                <el-breadcrumb-item>系统报表</el-breadcrumb-item>
                <el-breadcrumb-item>非标库报表</el-breadcrumb-item>
            </el-breadcrumb>
        </el-header>
        <el-header>
            <el-row >
                <el-col :xs="8" :sm="8" :md="4" :lg="2" :xl="2">
                    <el-button type="primary" icon="el-icon-edit" :offset="6" @click=exportSku>导出</el-button>
                </el-col>
                <el-col xs="14" :sm="14" :md="8" :lg="8" :xl="8">
                    <el-input placeholder="请输入内容" @keyup.enter.native="enterSearch" v-model="keySearch">
                        <el-button slot="append" icon="el-icon-search" @click=search></el-button>
                    </el-input>
                </el-col>
            </el-row>
        </el-header>
        <el-main>
            <el-table v-loading="loading" :data="tableData" stripe border style="width:100%" highlight-current-row size="mini"
                      tooltip-effect="dark" height="calc(100vh - 240px)">
                　　
                <el-table-column label="序号" align="center" width="50px">
                    　　
                    <template scope="scope"><span>{{scope.$index+(currentPage - 1) * pageSize + 1}}</span></template>
                </el-table-column>
                <el-table-column prop="sku_code" label="编号" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                　　
                <el-table-column prop="sku_name" label="名称" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                <el-table-column prop="sku_brand" label="品牌" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                <el-table-column prop="sku_unit" label="单位" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                <el-table-column prop="sku_slug_set" label="规格参数" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                <el-table-column prop="sku_price" label="售价" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
            </el-table>
        </el-main>
        <el-footer>
            <el-row>
                <el-col>
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                   :page-sizes="[100, 500, 1000]" :page-size="pageSize"
                                   layout="total, sizes, prev, pager, next, jumper"
                                   :total="totalRecords" >
                    </el-pagination>
                </el-col>
            </el-row>
        </el-footer>
    </el-container>
</div>

<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/dist/vue.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/index.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/publiccss/assets/global/plugins/jquery.min.js"
        type="text/javascript"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                tableData: [],
                currentPage: 1, //当前页
                pageSize: 100, //每页总数
                totalRecords: 0, //总条数
                keySearch: '',
                loading:false,
            };
        },
        methods: {
            exportSku() {
                window.location.href = "/dataCenter/nsl/export.json?key=" + this.keySearch;
            },
            //回车监听事件获取输入内容
            enterSearch(event) {
                this.currentPage=1;
                this.pageSize=100;
                this.keySearch = event.target.value;
                this.ajaxFunction();
            },
            //点击事件获取输入内容
            search() {
                this.currentPage=1;
                this.pageSize=100;
                this.ajaxFunction();
            },
            ajaxFunction: function () {
                this.loading=true;
                $.ajax({
                    url: '/dataCenter/nslList.json?page='+this.currentPage+'&limit='+this.pageSize+'&param='+this.keySearch,
                    type: 'get',
                    dataType: 'json',
                    success: (result)=> {
                        if (result.ret) {
                            this.tableData = result.data;
                            this.totalRecords = result.count;
                        }else{
                            this.$message.error('请求失败，请稍后重试');
                        }
                        this.loading=false;
                    }
                });
            },
            async handleSizeChange(val) {
                this.pageSize = val;
                this.ajaxFunction();
            },
            //
            async handleCurrentChange(val) {
                this.currentPage = val;
                this.ajaxFunction();
            },
        },
        mounted() {
            this.ajaxFunction();
        },
    })
</script>
</body>

</html>